/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mypomodoro;

/**
 *
 * @author lifsong
 */
public class StateModel extends Model <StateModelListener> {
    public enum PomodoroStates {INIT_STATE, WORKING_STATE, BREAK_STATE, INVALID_STATE};
    
    public final Property <PomodoroStates> state;
    
    public StateModel(){
        this.state = new Property <PomodoroStates> (PomodoroStates.INIT_STATE);
    }
 
    public void setNextStateWhenUserAction(PomodoroStates currentState){
        
        if(currentState == PomodoroStates.INIT_STATE){
            this.state.setValue(PomodoroStates.WORKING_STATE);
        }
        else if(currentState == PomodoroStates.WORKING_STATE){
            this.state.setValue(PomodoroStates.BREAK_STATE);
        }
        else if(currentState == PomodoroStates.BREAK_STATE){
            this.state.setValue(PomodoroStates.WORKING_STATE);
        }
        else{
            this.state.setValue(PomodoroStates.INIT_STATE);
        }
    }
    
    public void setNextStateWhenTimerExpired(PomodoroStates currentState){
        if(currentState == PomodoroStates.WORKING_STATE){
            this.state.setValue(PomodoroStates.INIT_STATE);
        }
        else if(currentState == PomodoroStates.BREAK_STATE){
            this.state.setValue(PomodoroStates.WORKING_STATE);
        }
        else{
            this.state.setValue(PomodoroStates.INIT_STATE);
        }
    }    
}
